<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test1</title>
</head>
<body>
<form name="form1" method="post" action="">
    用户名:<input name="user" type="text" id="user">
    密码:<input name="pwd" type="password" id="pwd">
    <input name="Button" type="submit" class="btn_grey" value="登录" onclick="check()">
    <input name="Submit2" type="reset" class="btn_grey" value="重置">
</form>

<script language="JavaScript">
    function check() {
        if (form1.user.value==""){
            alert("请输入用户名！");
        }else if(form1.pwd.value==""){
            alert("请输入密码！");
            form1.pwd.onfocus();
            return;
        }else {
            form1.submit();
        }
    }
</script>
</body>
</html>